function Account($scope, $http) {
	var uid = readData(localStorage.account);
	if (localStorage.userInfo) {
		//alert(readData(localStorage.userInfo));
		accounts = JSON.parse(readData(localStorage.userInfo));
		if (accounts.touxiang) {
			$scope.touxiang = accounts.touxiang
		} else {
			$scope.touxiang = "../../image/my/pl_tp.png";
		};
		if (accounts.accountNum) {
			$scope.accountNum = accounts.accountNum
		};
		if (!accounts.accountName) {
			$scope.accountName = "";
		} else {
			$scope.accountName = accounts.accountName;
		}
		if (!accounts.qianMing) {
			$scope.qianMing = "";
		} else {
			$scope.qianMing = accounts.qianMing;
		}
		if (!accounts.relaityName) {
			$scope.relaityName = "";
		} else {
			$scope.relaityName = accounts.relaityName;
		}
		if (accounts.sex) {
			if (accounts.sex == 'f') {
				$scope.sex = 0
			} else {
				$scope.sex = 1
			}
			//$scope.sex = accounts.sex
		};
		if (!accounts.email) {
			$scope.email = "";
		} else {
			$scope.email = accounts.email
		}
		if (!accounts.area) {
			$scope.area = "";
		} else {
			$scope.area = accounts.area;
		}
	} else {
		//请求服务器
		var url = getUrl("34personCenter");
		var headerJson = getHeader();
		$http({
			method: 'POST',
			url: url,
			headers: headerJson,
			timeout: 10000,
			//cache: true,
			params: {
				id: uid
			}
		}).success(function(data, status, headers, config) {
			if (data.code == "0") {
				accounts = data.obj;
				if (accounts.touxiang) {
					$scope.touxiang = accounts.touxiang;
				} else {
					$scope.touxiang = "../../image/my/pl_tp.png";
				};
				$scope.accountNum = accounts.accountNum
				if (!accounts.accountName) {
					$scope.accountName = "";
				} else {
					$scope.accountName = accounts.accountName
				}
				if (!accounts.qianMing) {
					$scope.qianMing = "";
				} else {
					$scope.qianMing = accounts.qianMing
				}
				if (!accounts.relaityName) {
					$scope.relaityName = "";
				} else {
					$scope.relaityName = accounts.relaityName
				}
				if (accounts.sex) {
					if (accounts.sex == 'f') {
						$scope.sex = 0
					} else {
						$scope.sex = 1
					}
				};
				if (!accounts.email) {
					$scope.email = "";
				} else {
					$scope.email = accounts.email;
				}
				if (!accounts.area) {
					$scope.area = "";
				} else {
					$scope.area = accounts.area;
				}
				localStorage.userInfo = writeData(JSON.stringify(accounts));
			}
		}).error(function() {
			mui.toast('网络链接异常，请稍后重试')
		});
	}
	//内容存到本地缓存中
	$scope.changeLocal = function() {
			var accounts = {};
			if (localStorage.userInfo) {
				accounts = eval('(' + readData(localStorage.userInfo) + ')');
			}
			accounts["touxiang"] = accounts.touxiang
			accounts["accountName"] = $scope.accountName;
			accounts["relaityName"] = $scope.relaityName;
			accounts["email"] = $scope.email;
			accounts["area"] = $scope.area;
			localStorage.userInfo = writeData(JSON.stringify(accounts));
			OpenNewWin({
				url: "sign.html",
				id: "sign.html"
			})
		}
		//提交个人账户信息
	$scope.upadateContent = function() {
		// alert(readData(localStorage.userInfo));
		if (!$scope.accountName) {
			mui.toast('昵称不能为空，请填写');
			return;
		}
		urlDd = getUrl("37updataAccount");
		headerDd = getHeader();
		sexs = JSON.parse(readData(localStorage.userInfo))["sex"];
		imgs = JSON.parse(readData(localStorage.userInfo))["touxiang"];
		paramdata = 'id=' + readData(localStorage.account) + '&nickname=' + $scope.accountName + '&signature=' + $scope.qianMing + '&trueName=' + $scope.relaityName + '&sex=' + sexs + '&email=' + $scope.email + '&address=' + $scope.area + '&headImg=' + imgs;
		plus.nativeUI.showWaiting("提交中");
		$http({
			method: 'POST',
			url: urlDd,
			headers: headerDd,
			timeout: 10000,
			data: paramdata
		}).success(function(data, status, headers, config) {
			plus.nativeUI.closeWaiting();
			if (data.msg == 'success') {

				localStorage.removeItem("userInfo");
				reloadHtml("personal.html")
				setTimeout(function() {
					mui.back()
				}, 500)

			} else {
				mui.toast(data.msg);

			};
		}).error(function(data, status, headers, config) {
			mui.toast('网络链接异常，请稍后重试(e)');
			plus.nativeUI.closeWaiting()
		});
	}
	var purl = getUrl("54uploadFile");
	var pheaderJson = getHeader();
	$scope.openImg = function() {
		var btnArray = [{
			title: "拍照"
		}, {
			title: "从相册选择"
		}];
		plus.nativeUI.actionSheet({
			title: "选择照片",
			cancel: "取消",
			buttons: btnArray
		}, function(e) {
			var index = e.index;
			switch (index) {
				case 0:
					break;
				case 1:
					var cmr = plus.camera.getCamera();
					cmr.captureImage(function(path) {
						uploadImg("file://" + plus.io.convertLocalFileSystemURL(path))
					}, function(err) {});
					break;
				case 2:
					plus.gallery.pick(function(path) {
						uploadImg(path)
					}, function(err) {}, null);
					break;
			}
		});
	}

	//图片上传
	function uploadImg(path) {
		plus.nativeUI.showWaiting("正在上传……")
		var task = plus.uploader.createUpload(purl, {
				method: "POST"
			},
			function(t, status) {
				//alert(JSON.stringify(t))
				// 上传完成				
				if (status == 200) {
					plus.nativeUI.closeWaiting()
					var str = t.responseText;
					if (!/\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/.test(str)) {
						mui.toast(str);
					} else {
						Receive(path, str)
					}
					plus.nativeUI.closeWaiting()
				} else {
					plus.nativeUI.closeWaiting();
					mui.toast("上传失败稍后再试");
				}

			});

		task.addFile(path, {
			key: "image"
		});
		task.start();
	}
}
//关闭窗体清除本地缓存
function closeW() {
	localStorage.removeItem("userInfo");
	api.closeWin();
}

//控制背景图片颜色的更换
var lis = document.getElementsByTagName("li");
for (var j = 1; j < lis.length; j++) {
	lis[j].num = j;
}
for (var i = 1; i < lis.length; i++) {
	lis[i].onclick = function() {
		for (var i = 1; i < lis.length; i++) {
			if (i != 2) {
				if (i == 6) {
					lis[i].getElementsByTagName("img")[0].src = "../../image/my/yuan0.png"
				} else {
					lis[i].getElementsByTagName("img")[0].src = "../../image/my/chilun0.png"
				}
			}
		}
		if (this.num != 2) {
			if (this.num == 6) {
				this.getElementsByTagName("img")[0].src = "../../image/my/yuan1.png"
			} else {
				this.getElementsByTagName("img")[0].src = "../../image/my/chilun1.png"
			}
		}
	}
}
//控制胡子背景
var btns = document.getElementsByClassName('buttons');
btns[0].onclick = function() {

	btns[0].className = "buttons btn_woman_0";
	btns[1].className = "buttons btn_man_0";
	changesex('f');
}
btns[1].onclick = function() {
	btns[1].className = "buttons btn_man_1";
	btns[0].className = "buttons btn_woman_1";
	changesex('m');
}

function changesex(str) {
	accounts = JSON.parse(readData(localStorage.userInfo));
	accounts["sex"] = str;
	localStorage.userInfo = writeData(JSON.stringify(accounts));
}

//函数控制上传关闭图片的隐藏于显示 obj代表被点击的对象 src取的图片的地址
function Receive(path, str) {
	var obj = document.getElementById('headImg');
	obj.src = path;
	accounts = JSON.parse(readData(localStorage.userInfo));
	accounts["touxiang"] = str;
	localStorage.userInfo = writeData(JSON.stringify(accounts));
}
window.addEventListener("refresh", function() {
	location.reload();
});
mui.back = function() {
	localStorage.removeItem("userInfo");
	plus.webview.currentWebview().close();

}